package Domain;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class DfaState extends State {
	private String id;
	private Set<NfaState> setOfStates;
	
	public DfaState() {
		super();
		setOfStates = new HashSet();
	}
	
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	public Set<NfaState> getSetOfStates() {
		return setOfStates;
	}
	
	public boolean addNfaState(NfaState s) {
		return setOfStates.add(s);
	}
	
	public List<StateTransition> getTransitions()
	{
		return super.transitions;
	}
	public void addTransition(StateTransition st)
	{
		super.transitions.add(st);
	}
	public void setTerminal(boolean isTerminal) {
		super.setTerminal(isTerminal);
	}

	public boolean isTerminal() {
		return super.isTerminal();
	}
	
	public String toString() {
		StringBuilder temp = new StringBuilder();
		for(State state : setOfStates) {
			temp.append( state.toString());
		}
		return super.toString();
		//return ((id != null)?(id + ": "):"") + temp.toString();
	}
	
	public boolean equals(DfaState other) {
		
		return (other.getSetOfStates().containsAll(this.getSetOfStates()))&&(this.getSetOfStates().containsAll(other.getSetOfStates())&&((!this.isTerminal()&&!other.isTerminal())||(this.isTerminal()&&other.isTerminal())));
		//return this.toString() == other.toString();
	}
}
